<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org"
      xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head th:include="include :: header"></head>
<body class="hold-transition skin-blue sidebar-mini">
<section class="content">
    <button class="btn btn-info pull-right" onclick="Print('#print')">打印</button>
    <div class="row" style="margin-top: 64px">
        <div class="col-xs-10 col-xs-offset-1">
            <div id="print">
                <table id="t1" class="t1">
                    <thead style="display: table-header-group">
                    <tr>
                        <td colspan="12">
                            <img th:src="@{/img/logo3.jpg}" width="64px" height="40px" style="margin-top: -30px">
                            <div style="display: inline-block;margin-top: 5px;margin-left: 20px">
                                <span style="letter-spacing: 24px;display: block;line-height: 20px">&nbsp;辽宁忠旺机械设备制造有限公司</span>
                                <span style="display: block;font-size: 12px;line-height: 20px">Liaoning Zhongwang Machinery Equipment Manufacturing Co., Ltd</span>
                            </div>
                        </td>
                        <td rowspan="2" style="width: 9%">
                            <div id="qrCode-div" style="display: none"></div>
                            <img id="qr-img" width="80px" height="80px">
                        </td>
                    </tr>
                    <tr>
                        <td colspan="12" style="font-size: 16px;letter-spacing: 4px;">
                            <span th:if="${sheet.reportType == 1}">外购件计划单</span>
                            <span th:if="${sheet.reportType == 2}">外协件计划单</span>
                            <span th:if="${sheet.reportType == 3}">原材料计划单</span>
                        </td>
                    </tr>
                    <tr>
                        <td colspan="2" style="width: 8%;">项目编号</td>
                        <td style="width: 10%;">
                            [[${sheet.proCode}]]
                        </td>
                        <td style="width: 8%">项目名称</td>
                        <td colspan="3" style="width: 30%">
                            [[${sheet.proName}]]
                        </td>
                        <td style="width: 8%">项目数量</td>
                        <td style="width: 6%">
                            [[${sheet.proNum}]]
                        </td>
                        <td style="width: 6%">类型</td>
                        <td style="width: 9%">
                            [[${sheet.malType}]]
                        </td>
                        <td style="width: 6%">部分</td>
                        <td style="width: 9%">
                            [[${sheet.part}]]
                        </td>
                    </tr>
                    <tr th:if="${sheet.reportType == 1}">
                        <td style="width: 4%;">序号</td>
                        <td colspan="4">物料描述</td>
                        <td style="width: 8%">数量</td>
                        <td style="width: 8%">单位</td>
                        <td colspan="2">型号/标准号</td>
                        <td colspan="2">品牌</td>
                        <td colspan="2">备注</td>
                    </tr>
                    <tr th:if="${sheet.reportType == 2}">
                        <td style="width: 4%;">序号</td>
                        <td colspan="4">物料描述</td>
                        <td colspan="3">图号</td>
                        <td>数量</td>
                        <td>单位</td>
                        <td>外协类型</td>
                        <td colspan="2">备注</td>
                    </tr>
                    <tr th:if="${sheet.reportType == 3}">
                        <td style="width: 4%;">序号</td>
                        <td colspan="4">物料描述</td>
                        <td style="width: 6%">数量</td>
                        <td style="width: 6%">单位</td>
                        <td>型号/标准号</td>
                        <td colspan="2">材质</td>
                        <td>使用库存</td>
                        <td colspan="2">备注</td>
                    </tr>
                    </thead>
                    <tbody th:if="${sheet.reportType == 1}">
                    <tr th:each="plan : ${plans}">
                        <td th:style="'color: ' + ${plan.isReturn == 1 ? 'red' : ''}" th:text="${planStat.count}">1</td>
                        <td th:style="'color: ' + ${plan.isReturn == 1 ? 'red' : ''}" colspan="4" th:text="${plan.malDesc}"></td>
                        <td th:style="'color: ' + ${plan.isReturn == 1 ? 'red' : ''}" th:text="${T(com.zw.pdm.util.BigDecimalUtils).valueFormat(plan.num)}"></td>
                        <td th:style="'color: ' + ${plan.isReturn == 1 ? 'red' : ''}" th:text="${plan.unit}"></td>
                        <td th:style="'color: ' + ${plan.isReturn == 1 ? 'red' : ''}" colspan="2" th:text="${plan.standard}"></td>
                        <td th:style="'color: ' + ${plan.isReturn == 1 ? 'red' : ''}" colspan="2" th:text="${plan.brand}"></td>
                        <td th:style="'color: ' + ${plan.isReturn == 1 ? 'red' : ''}" colspan="2" th:text="${plan.remark}"></td>
                    </tr>
                    </tbody>
                    <tbody th:if="${sheet.reportType == 2}">
                    <tr th:each="plan : ${plans}">
                        <td th:style="'color: ' + ${plan.isReturn == 1 ? 'red' : ''}" th:text="${planStat.count}">1</td>
                        <td th:style="'color: ' + ${plan.isReturn == 1 ? 'red' : ''}" colspan="4" th:text="${plan.malDesc}"></td>
                        <td th:style="'color: ' + ${plan.isReturn == 1 ? 'red' : ''}" colspan="3" th:text="${plan.diagram}"></td>
                        <td th:style="'color: ' + ${plan.isReturn == 1 ? 'red' : ''}" th:text="${T(com.zw.pdm.util.BigDecimalUtils).valueFormat(plan.num)}"></td>
                        <td th:style="'color: ' + ${plan.isReturn == 1 ? 'red' : ''}" th:text="${plan.unit}"></td>
                        <td th:style="'color: ' + ${plan.isReturn == 1 ? 'red' : ''}" th:text="${plan.assistType}"></td>
                        <td th:style="'color: ' + ${plan.isReturn == 1 ? 'red' : ''}" colspan="2" th:text="${plan.remark}"></td>
                    </tr>
                    </tbody>
                    <tbody th:if="${sheet.reportType == 3}">
                    <tr th:each="plan : ${plans}">
                        <td th:style="'color: ' + ${plan.isReturn == 1 ? 'red' : ''}" th:text="${planStat.count}">1</td>
                        <td th:style="'color: ' + ${plan.isReturn == 1 ? 'red' : ''}" colspan="4" th:text="${plan.malDesc}"></td>
                        <td th:style="'color: ' + ${plan.isReturn == 1 ? 'red' : ''}" th:text="${T(com.zw.pdm.util.BigDecimalUtils).valueFormat(plan.num)}"></td>
                        <td th:style="'color: ' + ${plan.isReturn == 1 ? 'red' : ''}" th:text="${plan.unit}"></td>
                        <td th:style="'color: ' + ${plan.isReturn == 1 ? 'red' : ''}" th:text="${plan.standard}"></td>
                        <td th:style="'color: ' + ${plan.isReturn == 1 ? 'red' : ''}" colspan="2" th:text="${plan.quality}"></td>
                        <td th:style="'color: ' + ${plan.isReturn == 1 ? 'red' : ''}" th:text="${plan.useStore == 1 ? '是' : '否'}"></td>
                        <td th:style="'color: ' + ${plan.isReturn == 1 ? 'red' : ''}" colspan="2" th:text="${plan.remark}"></td>
                    </tr>
                    </tbody>
                </table>
                <div class="row" style="font-size: 14px;line-height: 200%;">
                    <div class="col-xs-3" style="padding-left: 0">提报人：[[${sheet.postName}]]&nbsp;&nbsp;[[${#dates.format(sheet.commitTime,'yyyy.MM.dd')}]]</div>
                    <div class="col-xs-3">联系电话：[[${sheet.postTel}]]</div>
                    <div class="col-xs-3">审核：<span th:each="p : ${process}" th:if="${pStat.count == 1}">[[${p.verifyName}]]&nbsp;&nbsp;[[${#dates.format(p.verifyTime,'yyyy.MM.dd')}]]</span></div>
                    <div class="col-xs-3">批准：<span th:each="p : ${process}" th:if="${pStat.count == 2}">[[${p.verifyName}]]&nbsp;&nbsp;[[${#dates.format(p.verifyTime,'yyyy.MM.dd')}]]</span></div>
                </div>
            </div>
        </div>
        <div class="col-xs-1">
            <table id="t2" class="t2">
                <thead style="display: table-header-group">
                <tr><td></td></tr>
                <tr><td></td></tr>
                <tr><td></td></tr>
                <tr><td></td></tr>
                </thead>
                <tbody>
                <tr th:each="plan : ${plans}">
                    <td style="text-align: left">
                        <a target="_blank" style="margin-left: -10px" th:if="${plan.url != null}" th:href="${plan.url}">附件</a>
                        <span th:if="${plan.url == null}">&nbsp;</span>
                    </td>
                </tr>
                </tbody>
            </table>
        </div>
    </div>
</section>
<div th:include="include :: footer"></div>
<script th:inline="javascript">

    let gloDeptName = toUtf8('辽宁忠旺机械设备制造有限公司 ' + [[${sheet.deptName}]] + ' ' + [[${sheet.branchName}]]);

    $("#qrCode-div").qrcode({
        width: 80,
        height: 80,
        text: gloDeptName
    });

    $(function () {
        $("#t1 tr").each(function (i,v) {
            $("#t2 tr").eq(i).find("td").first().height($(this).find("td:first").height());
        })
        let c = document.getElementsByTagName('canvas')[0];
        $("#qr-img").attr("src", c.toDataURL("image/png"));
    });
</script>
</body>
</html>
